package com.zb.daoimpl;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.zb.dao.BaseDao;
import com.zb.dao.PartsDao;
import com.zb.entity.Msi;
import com.zb.entity.Parts;

public class PartsDaoImpl implements PartsDao{
	private BaseDao db=new BaseDao();
	public List<Parts> getPartsList() {
		List<Parts> list=new ArrayList<Parts>();
		String sql="select*from parts";
		ResultSet rs=db.query(sql);
		try {
			while(rs.next()) {
				Parts p=new Parts();
				Msi m=new Msi();
				p.setId(rs.getInt(1));
				m.setId(rs.getInt(2));
				p.setBland(rs.getString(3));
				p.setPrice(rs.getDouble(4));
				p.setImg(rs.getString(5));
				p.setMsi(m);
				list.add(p);
				return list;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			db.close();
		}
		return null;
	}

}
